//引入第三方组件
import Vue from 'vue'
import VueRouter from 'vue-router'
import axios from 'axios'
import vant from 'vant'
import 'mint-ui/lib/style.css'
import 'vant/lib/index.css'
import '../static/css/icon.css'
import { Indicator } from 'mint-ui';

//引入自己的组件
import App from './App.vue'
import Navigation from './components/navigation.vue'
import home from './components/home.vue' //主页
import qqSearch from './components/search/qqSearch.vue' //qq搜索组件
import musicList from './components/musicList/musicList.vue' //音乐电台列表
import inputSearch from './components/search/inputSearch.vue' //qq搜索页面
import musicContent from './components/musicList/musicContent.vue' //播放页面
import dynamic from './components/dynamic.vue' //动态
import recommend from './components/recommend.vue' //推荐
import mine from './components/mine.vue' //我的
import rankContent from './components/rank/rankContent.vue'

//定义全局组件或过滤器
Vue.component('qqSearch', qqSearch)
Vue.component('Navigation', Navigation)

//安装插件
Vue.use(VueRouter)
Vue.use(vant)

//挂载原型
Vue.prototype.$axios = axios

//拦截器的使用
axios.interceptors.request.use(function(config){
  Indicator.open('加载中...');
  return config
},function(error){
  return Promise.reject(error)
})
axios.interceptors.response.use(function(response){
  Indicator.close();
  return response
},function(error){
  return Promise.reject(error)
})

//动态请求地址
axios.defaults.baseURL = '/api'
//阻止启动生产消息
Vue.config.productionTip = false

//创建对象并配置路由
let router = new VueRouter({
  routes: [
    //配置路由规则
    {path: '/', redirect: {name: 'home'}},
    {name: 'dynamic', path: '/dynamic', component: dynamic, meta: {keepAlive: true}},
    {name: 'recommend', path: '/recommend', component: recommend, meta: {keepAlive: true}},
    {name: 'mine', path: '/mine', component: mine, meta: {keepAlive: true}},
    {name: 'home', path: '/home', component: home, meta: {keepAlive: true}},
    {name: '公共频道', path: '/musicList', component: musicList},
    {name: '音乐人频道', path: '/musicList', component: musicList},
    {name: 'inputSearch', path: '/music/search', component: inputSearch},
    {name: 'musicContent', path: '/music/content', component: musicContent},
    {name: 'rankContent', path: '/rank/content', component: rankContent},
  ]
})

//创建实例对象
new Vue({
  el: '#App',
  router,
  render: c => c(App)//render免去了编译过程
})



